package com.itheima.jdbc.homework;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

//- 添加：修改品牌
public class Test3 {
    public static void main(String[] args) throws SQLException {
        //- 修改一个品牌
        Brand brand = new Brand(4, "大炮手机", "大炮公司", 10000, "奥利给", 1);
        change(brand);
    }

    private static int change( Brand brand) throws SQLException {
        Connection connection = Connectionpoor.getConnection();
        String sql="update  tb_brand set brand_name=?,company_name=?,ordered=?,description=?,status=? where id=?";
        PreparedStatement preparedStatement = connection.prepareStatement(sql);
        preparedStatement.setString(1, brand.getBrand_name());
        preparedStatement.setString(2, brand.getCompany_name());
        preparedStatement.setInt(3, brand.getOrdered());
        preparedStatement.setString(4, brand.getDescription());
        preparedStatement.setInt(5, brand.getStatus());
        preparedStatement.setInt(6, brand.getId());
        int i = preparedStatement.executeUpdate();
        preparedStatement.close();
        connection.close();
        return i;
    }


}
